﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Mvc;

namespace Peninsula.DataAccess.POCO
{
    [Table("Admin")]
    public partial class Admin : BaseEntity
    {
        public Admin()
        {
            Roles = new HashSet<Role>();
        }

        [DisplayName("超级管理员？")]
        public bool IsSuperAdmin { get; set; }

        [Required(ErrorMessage ="必须填写")]
        [StringLength(50)]
        [DisplayName("用户名")]
        public string UserName { get; set; }

        [Required(ErrorMessage = "必须填写")]
        [StringLength(100)]
        [DisplayName("密码")]
        public string Password { get; set; }

        [Required(ErrorMessage = "必须填写")]
        [StringLength(50)]
        [DisplayName("真实姓名")]
        public string TrueName { get; set; }

        [Required(ErrorMessage = "必须填写")]
        [StringLength(50)]
        [DisplayName("手机")]
        [RegularExpression(@"^(0|86|17951)?(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$", ErrorMessage = "手机号码格式错误")]
        public string Phone { get; set; }

        [Required(ErrorMessage = "必须填写")]
        [StringLength(200)]
        [DisplayName("邮箱")]
        [RegularExpression(@"\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*", ErrorMessage = "邮箱格式错误")]
        public string Email { get; set; }

        [DisplayName("性别")]
        public Sex Sex { get; set; }
        //public string Postion { get; set; }

        [StringLength(500)]
        public string FaceImgPath { get; set; }

        /// <summary>
        /// 密码可重试次数
        /// </summary>
        public int FailedPasswordAttemptCount { get; set; }

        [DisplayName("锁定？")]
        public bool IsLockedOut { get; set; }

        [DisplayName("上次锁定日期")]
        public DateTime? LastLockoutDate { get; set; }

        [DisplayName("上次登录日期")]
        public DateTime? LastLoginDate { get; set; }

        [DisplayName("拥有角色")]
        public virtual ICollection<Role> Roles { get; set; }

        [StringLength(50)]
        [DisplayName("店面管理员")]
        public string StoreMangerId { get; set; }

        [ForeignKey("StoreMangerId")]
        public virtual StoreManger StoreManger { get; set; }

        [NotMapped]
        public List<SelectListItem> StoreMangers { get; set; }


        [StringLength(50)]
        [DisplayName("维修人员")]
        public string MaintenanceStafId { get; set; }

        [ForeignKey("MaintenanceStafId")]
        public virtual MaintenanceStaff MaintenanceStaff { get; set; }

        [NotMapped]
        public List<SelectListItem> MaintenanceStaffs { get; set; }

    }
}
